import { defineStore } from 'pinia'
export interface UserDataProps {
  username?: string
  id?: string
  phoneNumber?: string
  nickName?: string
  description?: string
  updatedAt?: string
  createdAt?: string
  iat?: number
  exp?: number
  picture?: string
  gender?: string
}
export interface UserProps {
  isLogin: boolean
  token: string
  data: UserDataProps
}
export const user = defineStore('user', {
  state: (): UserProps => {
    return {
      isLogin: false,
      token: '',
      data: {},
    }
  },
  actions: {
    login() {
      this.isLogin = true
      this.data = {
        id: '1',
        username: 'admin',
      }
    },
    fetchCurrentUser() {
      this.isLogin = true
      this.data = {
        id: '1',
        username: 'admin',
      }
    },
    logout: (state: UserProps) => {
      state.isLogin = false
      state.data = {}
    },
  },
})
